<template>
  <div class="scroll-category">
    <div class="product-tabs-outer">
      <div class="product-tabs">
        <div class="tabs-list">
          <div 
            class="item" 
            :class="{'item-cur': currentIndex === index && hasCurrent}"
            v-for="(item, index) in categories" 
            :key="index"
            @click="tabClicked(index)"
          >
            <span>{{item.Name}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    categories: {
      type: Array,
      default: [],
    },
    currentIndex: {
      type: Number,
      default: 0,
    },
    hasCurrent: {
      type: Boolean,
      default: true,
    },
  },
  methods: {
    tabClicked(item){
      this.$emit('itemClicked', item)
    }
  },
}
</script>

<style scoped>
.product-tabs-outer{
  overflow: hidden;
  margin-bottom: 10px;
  background-color: #fff;
}
.product-tabs{
  width: 100%;
  overflow: auto;
  margin-top: 5px;
  padding-bottom: 20px;
  margin-bottom: -20px;
}
.product-tabs::-webkit-scrollbar {
  width: 0;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none;
  overflow: -moz-scrollbars-none;
  height: 0;
  background-color: rgba(240,240,240,0)
}
.product-tabs .tabs-list{
  display: flex;
}
.product-tabs .tabs-list .item{
  flex-shrink: 0;
  min-width: 60px;
  padding: 0 20px 0 0;
  height: 43px;
  line-height: 40px;
  margin-left: 10px;
  text-align: center;
  font-size: 14px;
  box-sizing: border-box;
}
.product-tabs .tabs-list .item span{
  display: inline-block;
  border-bottom: 3px solid #ffffff;
}
.product-tabs .tabs-list .item-cur span{
  color: #d50721;
  border-bottom: 3px solid #d50721;
}

/* index */
.sc-index .product-tabs-outer{
  position: relative;
  background: none;
  margin-bottom: 0;
}
.sc-index .product-tabs .tabs-list .item{
  position: relative;
}
.sc-index .product-tabs .tabs-list .item span{
  font-size: 16px;
  font-weight: bold;
  border-bottom: 3px solid rgba(255, 255, 255, 0);
  margin-bottom: -3px;
}
.sc-index .product-tabs .tabs-list .item-cur span{
  border-bottom: 3px solid rgba(255, 255, 255, 0);
}
.sc-index .product-tabs .tabs-list .item:after{
  position: absolute;
  right: 4px;
  top: 12px;
  display: block;
  content: '';
  width: 1px;
  height: 14px;
  background: #d4d4d4;
}
.sc-index .product-tabs .tabs-list .item:last-child:after{
  display: none;
}
</style>